<?php
/**
 * Zhub - A PHP Framework For API Developer
 *
 * This file is part of the Zhub package.
 *
 * (c) YiLong Fan <fantiq@163.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author fanyilong <fantiq@163.com>
 * @copyright 2017 fanyilong. All rights reserved.
 * @package Zhub
 * @date 18-3-7
 */

namespace Zhub\DataBase\Grammar\MySQL;


use Zhub\DataBase\Grammar\Grammar;

class Delete extends Grammar
{

    const WHERE = 0b0;

    public function where(string $where)
    {
        $this->sqlComponent[self::WHERE] = $where;
    }

    public function toSQL(): string
    {
        $where = $this->sqlComponent[self::WHERE];
        return "DELETE $this->tableName" .
            $where ? " WHERE $where" : '';
    }

    public function initialize()
    {
        parent::initialize();
        $this->sqlComponent = [
            self::WHERE => null
        ];
    }

}